home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
c
/
gymake12.zip
/
MAKE.DOC
< prev
next >
Wrap
Text File
|
1988-11-18
|
16KB
|
390 lines
NAME
make - maintain, update, and reconstruct groups of programs
SYNOPSIS
make [-f makefile] [-dDeinrst] [target...] [macro=value ...]
DESCRIPTION
MAKE takes a file of dependencies (a 'makefile') and decides what
commands have to be executed to bring the files up to date. These
commands are either executed directly from MAKE or written to the
standard output without executing them.
If no makefile is specified with a -f option, MAKE reads a file
named `makefile', if it exists.
If no target is specified on the command line, MAKE uses the first
target defined in the first makefile.
OPTIONS
-f makefile
Use the description file `makefile'. A - as the makefile
argument denotes the standard input.
-d Display the reasons why MAKE chooses to rebuild a target. All
dependencies which are newer are displayed
-dd Display the dependency checks in more detail. Dependencies
which are older are displayed, as well as newer.
-D Display the text of the makefiles as read in.
-DD Display the text of the makefiles and `default.mk'.
-e Let environment variables override macro definitions from
makefiles. Normally, makefile macros override environment
variables. Command line macro definitions always override both
environment variables and makefile macros definitions.
-i Ignore error codes returned by commands. This is equivalent to
the special target .IGNORE:.
-n No execution mode. Print commands, but do not execute them.
Even lines beginning with an @ are printed. However, if a
command line is an invocation of MAKE, that line is always
executed.
-r Do not read in the default file `default.mk'.
-s Silent mode. Do not print command lines before executing them.
This is equivalent to the special target .SILENT:.
-t Touch the target files, bringing them up to date, rather than
performing the rules to reconstruct them.
macro=value
Macro definition. This definition remains fixed for the MAKE
invocation. It overrides any regular definitions for the
specified macro within the makefiles and from the environment.
It is inherited by subordinate MAKE's but act as an environment
variable for these. That is, depending on the -e setting, it
may be overridden by a makefile definition.
USAGE
Makefiles
The first makefile read is `default.mk', which can be located any-
where along the PATH. It typically contains predefined macros and
implicit rules.
The default name of the makefile is `makefile' in the current
directory. An alternate makefile can be specified using one or
more '-f' options on the command line. Multiple '-f's act as the
concatenation of all the makefiles in a left-to-right order.
The makefile(s) may contain a mixture of comment lines, macro
definitions, include lines, and target lines. Lines may be
continued across input lines by escaping the NEWLINE with a
backslash (\).
Anything after a "#" is considered to be a comment, and is stripped
from the line. Completely blank lines are ignored.
An include line is used to include the text of another makefile.
It consists of the word "include" left justified, followed by
spaces, and followed by the name of the file that is to be included
at this line. Include files may be nested.
Macros
Macros have the form `WORD = text and more text'. The WORD need
not be uppercase, but this is an accepted standard. Later lines
which contain $(WORD) or ${WORD} will have this replaced by `text
and more text'. If the macro name is a single character, the
parentheses are optional. Note that the expansion is done
recursively, so the body of a macro may contain other macro
invocations.
e.g. FLINTSTONES = wilma and fred
RUBBLES = barney and betty
BEDROCK = $(FLINTSTONES) and $(RUBBLES)
`$(BEDROCK)' becomes `wilma and fred and barney and betty'
Also note that whitespace around the equal sign is not relevant
when defining a macro. The following four macro definitions are
all equivalent:
MACRO = body
MACRO= body
MACRO =body
MACRO=body
Macros may be added to by using the `+=' notation. Thus
FLINTSTONES += pebbles and dino
would be (given the examples above) the same as
FLINTSTONES = wilma and fred and pebbles and dino
Special Macros
MAKE
This normally has the value "make". Any line which invokes
MAKE temporarily overrides the -n option, just for the duration
of the one line. This allows nested invocations of MAKE to be
tested with the -n option.
MAKEFLAGS
This macro has the set of options provided to MAKE as its
value. If this is set as an environment variable, the set of
options is processed before any command line options. This
macro may be explicitly passed to nested MAKEs, but it is also
available to these invocations as an environment variable.
SUFFIXES
This contains the default list of suffixes supplied to the
special target .SUFFIXES:. It is not sufficient to simply
change this macro in order to change the .SUFFIXES: list. That
target must be specified in your makefile.
There are several dynamically maintained macros that are useful as
abbreviations within rules. It is best not to define them
explicitly.
$* The basename of the current target.
$< The name of the current dependency file.
$@ The name of the current target.
The $< and $* macros are normally used for implicit rules. They
may be unreliable when used within explicit target command lines.
Targets
A target entry in the makefile has the following format:
target ... : [dependency ...]
[rule]
...
Any line which does not have leading whitespace (other than macro
definitions) is a `target' line. Target lines consist of one or
more filenames (or macros which expand into same) called targets,
followed by a semi-colon (:). The ':' is followed by a list of
dependent files.
Special allowance is made on MSDOS for the colons which are needed
to specify files on other drives, so for example, the following
will work as intended:
c:foo.bar : a:fee.ber
If a target is named in more than one target line, the dependencies
and rules are added to form the target's complete dependency list
and rule list.
The dependents are ones from which a target is constructed. They
in turn may be targets of other dependents. In general, for a
particular target file, each of its dependent files is `made', to
make sure that each is up to date with respect to it's dependents.
The modification time of the target is compared to the modification
times of each dependent file. If the target is older, one or more
of the dependents have changed, so the target must be constructed.
Of course, this checking is done recursively, so that all
dependents of dependents of dependents of ... are up to date.
To reconstruct a target, MAKE expands macros, strips off initial
whitespace, and either executes the rules directly, or passes each
to a shell or COMMAND.COM for execution.
For target lines, macros are expanded on input. All other lines
have macro expansion delayed until absolutely required.
Special Targets
.DEFAULT:
The rule for this target is used to process a target when there
is no other entry for it, and no implicit rule for building it.
MAKE ignores all dependencies for this target.
.DONE:
This target and its dependencies are processed